home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1995 November / Macworld Nov ’95.toast / Developers / BoxMaker++ / BoxMaker++ ƒ / headers / standardgetfile.h < prev   
Encoding:
Text File  |  1995-06-14  |  2.6 KB  |  112 lines  |  [TEXT/KAHL]

  1. //
  2. // standardgetfile is a base class to interface to CustomGetFile
  3. //
  4. // Note for CodeWarriors: if your compiler complains that it can not
  5. // use a struct as a base class for standardgetfile you probably are using
  6. // a precompiled header file generated with the C compiler with this C++
  7. // code. You should recompile them with the C++ compiler, and all should
  8. // be fine.
  9. //
  10. class standardgetfile : protected StandardFileReply
  11. {
  12.     public:
  13.         standardgetfile( short dlogID = sfGetDialogID,
  14.             OSType *thetypes = 0L, long numtypes = -1, short *activelist = nil);
  15.  
  16.         ~standardgetfile();
  17.  
  18.         void changeTypes( OSType *thetypes, long numtypes);
  19.  
  20.         Boolean doIt();
  21.  
  22.         const StandardFileReply &operator()();
  23.  
  24.         //
  25.         // Functions to read the list of types accepted by this application,
  26.         // as read from the 'typs' resource #128. Present for use by subclasses.
  27.         //
  28.         const OSType *GetTheTypes() const;
  29.         short GetNumTypes() const;
  30.  
  31.     protected:
  32.         //
  33.         // override these four virtual members when appropriate
  34.         //
  35.         virtual Boolean filterThisItem( const CInfoPBPtr myPB)
  36.         {
  37.             //
  38.             // default: filter out invisible files
  39.             //
  40.             return ((myPB->hFileInfo.ioFlFndrInfo.fdFlags & fInvisible) != 0);
  41.         };
  42.  
  43.         virtual short handleItemPress(
  44.                                 short item, DialogPtr theDialog)
  45.         {
  46.             return item;            
  47.         };
  48.  
  49.         virtual Boolean filterEvent( DialogPtr theDialog,
  50.                         const EventRecord *theEvent, short *itemHit)
  51.         {
  52.             return false;
  53.         }
  54.  
  55.         virtual void handleActivation(
  56.                 DialogPtr theDialog, short item, Boolean activating)
  57.         {
  58.         
  59.         }
  60.  
  61.         OSType        *theTypes;
  62.         long        numTypes;
  63.  
  64.     private:
  65.         //
  66.         // The four functions to pass to CustomGetFile and
  67.         // their UPP's:
  68.         //
  69.         friend static pascal Boolean theFileFilter(
  70.                                             CInfoPBPtr myPB, Ptr myDataPtr);
  71.  
  72.         friend static pascal short theDlogHook(
  73.                         short item, DialogPtr theDialog, Ptr myDataPtr);
  74.  
  75.  
  76.         friend static pascal Boolean theModalFilter(
  77.                                             DialogPtr theDialog,
  78.                                             const EventRecord *theEvent,
  79.                                             short *itemHit, Ptr myDataPtr);
  80.  
  81.         friend static pascal void theActivate(
  82.                                             DialogPtr theDialog,
  83.                                             short item,
  84.                                             Boolean activating, Ptr myDataPtr);
  85.  
  86.         static FileFilterYDUPP        theFileFilterUPP;
  87.         static DlgHookYDUPP            theDlogHookUPP;
  88.         static ModalFilterYDUPP        theModalFilterUPP;
  89.         static ActivateYDUPP        theActivateUPP;
  90.  
  91.         void setTypes( OSType *thetypes, long numtypes);
  92.  
  93.         const short    DLOG_ID;
  94.         short        *activeList;
  95. };
  96.  
  97. inline const StandardFileReply &standardgetfile::operator()()
  98. {
  99.     return (const StandardFileReply &)(*this);
  100. }
  101.  
  102. inline const OSType *standardgetfile::GetTheTypes() const
  103. {
  104.     return (OSType * const)theTypes;
  105. }
  106.  
  107. inline short standardgetfile::GetNumTypes() const
  108. {
  109.     return numTypes;
  110. }
  111.  
  112.